package cn.xy.dao;

import cn.xy.pojo.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 *  使用注解实现增删改查
 */
public interface TeacherMapper {

    @Select("select * from `teacher`;")
    List<Teacher> getTeacherList();

    //增
    @Insert("insert into `teacher` (tid,tname,cid) values (#{tid},#{tname},#{cid});")
    int insertTeacher(Teacher teacher);

    //删
    @Delete("delete from `teacher` where tid = #{tid};")
    int deleteTeacher(@Param("tid")int id);

    //改
    @Update("update `teacher` set tname=#{tname},cid=#{cid} where tid=#{tid};")
    int updateTeacher(Teacher teacher);

    //查
    @Select("select * from `teacher` where tid=#{tid};")
    Teacher selectTeacher(@Param("tid")int id);
}
